<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2017/12/27
 * Time: 19:31
 */

namespace App\Http\Traits;



use Illuminate\Http\Request;

trait TagTrait
{
    use BaseTrait;

    // 标签名称
    protected $name;
    // 父ID
    protected $parent_id;
    // 分页大小
    protected $limit;
    // 标签ID
    protected $tag_id;
    // 分类ID
    protected $category_id;
    // 是否是单选
    protected $is_radiobox;
    // 分类图标
    protected $icon;
    // 分类图标文件
    protected $icon_file;

    public function __construct(Request $request)
    {
        $this->name = $request->input('name', '');
        $this->parent_id = $request->input('parent_id', 0);
        $this->limit = $request->input('limit', 0);
        $this->tag_id = $request->input('tag_id', 0);
        $this->category_id = $request->input('category_id', 0);
        $this->is_radiobox = $request->input('is_radiobox', 0);
        $this->icon = $request->input('icon', '');
        if (!empty($request->file('file', ''))){
            $this->icon_file = $request->file('file', '')->store('temp');
        }
    }
}